package com.czl.elm.controller;


import com.czl.elm.domain.Shop;
import com.czl.elm.domain.Shopdetails;
import com.czl.elm.service.IShopService;
import com.czl.elm.util.ActionResult;
import com.czl.elm.util.RespPageBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zuoleiChen
 * @since 2021-05-21
 */
@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private IShopService shopService;

    @ApiOperation(value = "查询所有商家，并分页")
    @GetMapping("/selectAll")
    public ActionResult selectAllShop( Integer currentPage,  Integer size){
        //System.out.println("cur:"+currentPage+"    size:"+size);
        RespPageBean res=shopService.selectAllShop(currentPage,size);
        if(res==null){
            return ActionResult.error("获取失败");
        }
        return ActionResult.success("获取成功",res);
    }

    @ApiOperation(value = "查询商店基本信息")
    @GetMapping("/selectshopbasic/{shopid}")
    public ActionResult selectShopBasic(@PathVariable Integer shopid){
        Shop res=shopService.selectShopBasic(shopid);
        if(res==null){
            return ActionResult.error("没有该数据");
        }
        return ActionResult.success("获取成功",res);
    }
    @ApiOperation(value = "查询商店详情")
    @GetMapping("/selectshopdetails/{shopid}")
    public ActionResult selectShopDetails(@PathVariable Integer shopid){
        Shopdetails res=shopService.selectShopDetails(shopid);
        if(res==null){
            return ActionResult.error("没有该数据");
        }
        return ActionResult.success("获取成功",res);
    }

    @ApiOperation(value = "获取商店菜单详情")
    @GetMapping("/selectmenu/{shopid}")
    public ActionResult selectShopMenu(@PathVariable Integer shopid){
        Map<String, Object> res=shopService.selectShopMenu(shopid);
        if(res==null){
            return ActionResult.error("没有该数据");
        }
        return ActionResult.success("获取成功",res);
    }


    @ApiOperation(value = "获取商店优惠详情")
    @GetMapping("/selectpreferential/{shopid}")
    public ActionResult selectPreferential(@PathVariable Integer shopid){
        return shopService.selectPreferential(shopid);

    }







}
